//
//  MyFirstCell.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/8/27.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class MyFirstCell: UITableViewCell {
    
    var settingIcon:UIButton!//设置按钮
    var avatar:UIImageView!//头像
    var userName:UILabel!//用户名
    var rankLabel:UILabel!//排名
    var concernsLabel:UILabel!//关注的数字
    var concerns:UILabel!//关注的文字
    var fansLabel:UILabel!//粉丝的数字
    var fans:UILabel!//粉丝的文字
    var commentLabel:UILabel!//评论的数字
    var comment:UILabel!//评论的文字
    var smallDot:UIImageView!//红色的小圆点 有新评论的时候出现
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        settingIcon = UIButton()
        avatar = UIImageView()
        userName = UILabel()
        rankLabel = UILabel()
        concernsLabel = UILabel()
        concerns = UILabel()
        fansLabel = UILabel()
        fans = UILabel()
        commentLabel = UILabel()
        comment = UILabel()
        smallDot = UIImageView()
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .None
        self.createSettingIcon()
        self.createAvatar()
        self.createUserNameLabel()
        self.createRankLabel()
        self.createConcernsLabel()
        self.createFansLabel()
        self.createComment()
        self.createSmallDot()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

//MARK:--UI
extension MyFirstCell{
    //创建左上角setting 按钮
    func createSettingIcon(){
        settingIcon.frame = CGRect(x: 24*SCALEW,y: 38*SCALEH,width: 20,height: 20)
        settingIcon.setImage(UIImage(named: "settingIcon"), forState: UIControlState())
        self.addSubview(settingIcon)
    }
    
    //创建头像
    func createAvatar(){
        avatar.frame = CGRect(x: 148*SCALEW, y: 68*SCALEH, width: 79*SCALEW, height: 79*SCALEW)
        avatar.userInteractionEnabled = true
        self.addSubview(avatar)
    }
    
    //创建用户名
    func createUserNameLabel(){
        userName.frame = CGRect(x: 0, y: 157*SCALEH, width: WidthAPP, height: 17*SCALEH)
        userName.font = BaseFunc.getCustomFont(12)
        userName.textAlignment = .Center
        userName.textColor = Theme.GrayColor
        self.addSubview(userName)
    }
    
    //创建rankLabel
    func createRankLabel(){
        rankLabel.frame = CGRect(x: 0, y: 176*SCALEH, width: WidthAPP, height: 28*SCALEH)
        rankLabel.font = BaseFunc.getCustomFont(20)
        rankLabel.textAlignment = .Center
        rankLabel.textColor = UIColor.blackColor()
        self.addSubview(rankLabel)
    }
    
    
    //创建 关注 的文字 和数字
    func createConcernsLabel(){
        concernsLabel.frame = CGRect(x: 32*SCALEW, y: 227*SCALEH, width: 44*SCALEW, height: 20*SCALEH)
        concernsLabel.font = BaseFunc.getCustomFont(14)
        concernsLabel.textAlignment = .Center
        concernsLabel.textColor = BaseFunc.createCustomColor(201, b: 0, g: 0, a: 1)
        concernsLabel.userInteractionEnabled = true
        self.addSubview(concernsLabel)
        
        concerns.frame = CGRect(x: 37*SCALEW, y: 247*SCALEH, width: 32*SCALEW, height: 21*SCALEH)
        concerns.font = BaseFunc.getCustomFont(15)
        concerns.textAlignment = .Center
        concerns.textColor = UIColor.blackColor()
        concerns.text = "关注"
        self.addSubview(concerns)
    }
    
    //添加粉丝 的 文字和 数字
    func createFansLabel(){
        fansLabel.frame = CGRect(x: 165*SCALEW, y: 227*SCALEH, width: 47*SCALEW, height: 20*SCALEH)
        fansLabel.font = BaseFunc.getCustomFont(14)
        fansLabel.textAlignment = .Center
        fansLabel.textColor = BaseFunc.createCustomColor(201, b: 0, g: 0, a: 1)
        fansLabel.userInteractionEnabled = true
        self.addSubview(fansLabel)
        
        fans.frame = CGRect(x: 172*SCALEW, y: 247*SCALEH, width: 32*SCALEW, height: 21*SCALEH)
        fans.font = BaseFunc.getCustomFont(15)
        fans.textAlignment = .Center
        fans.textColor = UIColor.blackColor()
        fans.text = "粉丝"
        self.addSubview(fans)
    }
    
    //添加评论 
    func createComment(){
        commentLabel.frame = CGRect(x: 301*SCALEW, y: 227*SCALEH, width: 38*SCALEW, height: 20*SCALEH)
        commentLabel.font = BaseFunc.getCustomFont(14)
        commentLabel.textAlignment = .Center
        commentLabel.textColor = BaseFunc.createCustomColor(201, b: 0, g: 0, a: 1)
        commentLabel.userInteractionEnabled = true
        self.addSubview(commentLabel)
        
        comment.frame = CGRect(x: 304*SCALEW, y: 247*SCALEH, width: 32*SCALEW, height: 21*SCALEH)
        comment.font = BaseFunc.getCustomFont(15)
        comment.textAlignment = .Center
        comment.textColor = UIColor.blackColor()
        comment.text = "评论"
        self.addSubview(comment)
    }
    
    
    //添加有新评论的时候的小圆点
    func createSmallDot(){
        smallDot.frame = CGRect(x: 333*SCALEW, y: 248*SCALEH, width: 6*SCALEW, height: 6*SCALEH)
        smallDot.image = UIImage(named: "littleRedIcon")
        self.addSubview(smallDot)
    }
    
}













